package it.crosato.stage.server.model.comparison;

import static org.junit.Assert.*;

import java.util.Vector;

import it.crosato.stage.server.model.retriever.PathwayRetriever;
import it.crosato.stage.shared.exceptions.NonExistentException;
import it.crosato.stage.shared.exceptions.RetrievingException;
import it.crosato.stage.shared.objects.Match;
import it.crosato.stage.shared.objects.MultisetsGroup;
import it.crosato.stage.shared.objects.Pathway;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class InvariantsComparatorTest {

	@Test
	public void testGetDistanceMatrix() {
		try {
			Pathway[][] pathways = new Pathway[2][1];
			pathways[0][0] = new PathwayRetriever().getPathway("path:map00020", "hsa", 604800000);
			pathways[1][0] = new PathwayRetriever().getPathway("path:map00020", "pan", 604800000);
			String path = System.getProperty("user.home") + "/";
			IInvariantsModeller invModeller = new InvariantsModeller();
			MultisetsGroup[][] invs = invModeller.getPathwaysModels(pathways, true, "sid", path);
			Vector<Match[][]> matches = new Vector<Match[][]>();
			IInvariantsComparator invComparator = new InvariantsComparator();
			double[][] dm = invComparator.getDistanceMatrix(invs, matches);
			assertTrue(dm != null && dm[0][0] == 0 && dm[1][1] == 0 && dm[0][1] == dm[1][0]);
		}
		catch (RetrievingException re) { }
		catch (NonExistentException ne) { }
	}
	
	@Before
	public void setUp() {
		
	}
	
	@After
	public void tearDown() {
		
	}

}
